<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
</head>

<body>
    <header class="aui-bar aui-bar-nav" style="background-color: #03a9f4;position:fixed;" id="header">
        <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            A类变化点确认
        </div>
    </header>
    <div class="aui-content aui-margin-b-15" style="margin-top:60px;">
        <ul class="aui-list aui-form-list">
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">变化内容</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="content">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">处理措施</div>
                    <div class="aui-list-item-input">
                        <select id="measureName">
                      </select>
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">备注</div>
                    <div class="aui-list-item-input">
                        <textarea id="remark"></textarea>
                    </div>
                </div>
            </li>
        </ul>
    </div>

    <div class='aui-btn aui-btn-info aui-btn-block' style="margin-top:10px;" onclick='save()'>确认</div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript">
    //变化点发起记录id
    var sysid = "";
    //任务id
    var taskId = "";
    //变化点分类id
    var pointOfChangeId = "";
    apiready = function() {

        reset();
        sysid = api.pageParam.sysid;
        taskId = api.pageParam.taskId;
        pointOfChangeId = api.pageParam.pointOfChangeId;

        $("#content").val(api.pageParam.content);

        //查询处理措施
        getCombox();
    };

    //清空表单数据
    function reset() {
        sysid = "";
        taskId = "";
        pointOfChangeId = "";
        $("#content").val("");
        $api.html($api.byId("measureName"), "");
        $("#remark").val("");
    }

    //查询下拉框
    function getCombox() {
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getUtilComboxList";
        var data = {
            values: {
                tablename: "qc_point_measure_rel",
                column_name: "content",
                column_value: "content",
                condition: "point_of_change_id = '" + pointOfChangeId + "' and is_delete=0",
                un:un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function(ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var map = eval("(" + data + ")");
                var list = eval(map.list);
                var html = "";
                for (var i = 0; i < list.length; i++) {
                    html += "<option value='" + list[i].value + "'>" + list[i].label + "</option>";
                }
                $api.html($api.byId("measureName"), html);
            }
        });
    }

    //发起保存
    function save() {
        //处理措施
        var measureName = $("#measureName").val();
        //备注
        var remark = $("#remark").val();

        api.showProgress({
            title: '保存中...',
        });
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/qcPointChangeSaveConfirmA";
        var data = {
            values: { ////以表单方式提交参数（JSON对象）
                sysid: sysid,
                taskId: taskId,
                measureName: measureName,
                remark: remark,
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function(ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                //成功
                if (myobj.code == '0') {

                    api.hideProgress();
                    api.toast({
                        msg: "保存成功",
                        duration: 3000
                    });

                    //返回上一菜单
                    closeWin();
                } else if (myobj.code == '1') {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            } else {
                api.hideProgress();
                alert(JSON.stringify(err));
            }
        });
    }


    //清空
    function reset() {
        $api.html($api.byId("classFlag"), "");
        $api.html($api.byId("pointClass"), "");
        $api.html($api.byId("pointOfChangeId"), "");
        $("#opId").val("");
        $("#opCode").val("");
        $("#opName").val("");
        $("#mrlCode").val("");
        $("#mrlName").val("");
        $("#equipCode").val("");
        $("#equipName").val("");
        $("#remark").val("");
    }

    //返回按钮
    function closeWin() {
        api.closeWin({});

        api.execScript({
            name: "qcPointChangeTaskA",
            script: 'doSearch()'
        });
    }
</script>

</html>
